package ahblue.cn.tanzi.model.home;

import android.content.Context;
import android.widget.Toast;

import java.util.List;

import ahblue.cn.tanzi.data.source.ApiCallback;
import ahblue.cn.tanzi.data.source.RemoteRepository;
import ahblue.cn.tanzi.model.user.LoginResultModel;
import ahblue.cn.tanzi.util.PinkJSON;

/**
 * @author pink-jackstraw
 * @date 2018/11/19
 * @describe
 */
public class VideoLableModel {

    public String id;
    public String category_title;

    /**
     * 获取lable
     * @param context
     * @param mListener
     */
    public static void getLable(final Context context,final VideoLableResult mListener){
        RemoteRepository repo = RemoteRepository.getsInstance();
        repo.getLable( new ApiCallback<List<VideoLableModel>>(){
            @Override
            public void onSuccess(List<VideoLableModel> data) {
                LoginResultModel.saveUserInfo(context, PinkJSON.toJSON(data).toString());
                if (null!=mListener){
                    mListener.conver(data);
                }
            }
            @Override
            public void onFailed(String errorMsg) {
                Toast.makeText(context,errorMsg,Toast.LENGTH_LONG).show();
                if (null!=mListener){
                    mListener.conver(null);
                }
            }
        });
    }

    public interface VideoLableResult {
        void conver(List<VideoLableModel> model);
    }

}
